home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 001-010 / amok07 / m2tests / testfilesystem.mod < prev    next >
Text File  |  1993-11-04  |  4KB  |  126 lines

  1. (****************************************************************
  2.  *                                                              *
  3.  *  :Program.    TestFileSystem.mod                             *
  4.  *  :Author.     Michael Frieß                                  *
  5.  *  :Address.    Kernerstr. 22a                                 *
  6.  *  :shortcut.   [MiF]                                          *
  7.  *  :Version.    1.0                                            *
  8.  *  :Date.       30.09.88                                       *
  9.  *  :Copyright.  PD                                             *
  10.  *  :Language.   Modula-II                                      *
  11.  *  :Translator. M2Amiga                                        *
  12.  *  :Contents.   Test of module FileSystem                      *
  13.  *                                                              *
  14.  ****************************************************************)
  15.  
  16. MODULE TestFileSystem;
  17.  
  18. FROM SYSTEM     IMPORT ADR;
  19. FROM FileSystem IMPORT Lookup, Close, ReadByteBlock, ReadBytes,
  20.                        WriteByteBlock, WriteBytes, File,
  21.                        SetPos;
  22. FROM Strings    IMPORT Length;
  23. FROM InOut    IMPORT WriteInt, WriteString, WriteLn,
  24.                      OpenOutput, CloseOutput;
  25.  
  26. TYPE String = ARRAY [1..10] OF CHAR;
  27.  
  28. PROCEDURE TestWriteByteBlock (str: String);
  29.  VAR f     : File;
  30.      result: String;
  31.      act   : LONGINT;
  32.  BEGIN
  33.   Lookup (f, "t:TestFileSystem.tmp", 0, TRUE);
  34.   WriteString (" PROCEDURE WriteByteBlock"); WriteLn;
  35.   WriteString ("  block = "); WriteString (str); WriteLn;
  36.   WriteByteBlock (f, str);
  37.   Close (f);
  38.  
  39.   Lookup (f, "t:TestFileSystem.tmp", 0, FALSE);
  40.   WriteString (" PROCEDURE ReadByteBlock"); WriteLn;
  41.   ReadByteBlock (f, result);
  42.   WriteString ("  block = "); WriteString (result); WriteLn;
  43.   IF Length(result) = SIZE(result) THEN
  44.     WriteString ("Ergebnis ist korrekt.")
  45.   ELSE
  46.     WriteString ("FEHLER!!")
  47.   END;
  48.   WriteLn;
  49.  
  50.   SetPos (f, 0);
  51.   WriteString (" PROCEDURE ReadBytes"); WriteLn;
  52.   ReadBytes (f, ADR(result), SIZE(result), act);
  53.   WriteString ("  block = "); WriteString (result); WriteLn;
  54.   WriteString ("  actual = "); WriteInt (act, 3); WriteLn;
  55.   IF act = SIZE(result) THEN
  56.     WriteString ("Ergebnis ist korrekt.")
  57.   ELSE
  58.     WriteString ("FEHLER!!")
  59.   END;
  60.   WriteLn;
  61.   Close (f);
  62.  END TestWriteByteBlock;
  63.  
  64.  
  65. PROCEDURE TestWriteBytes (str: String);
  66.  VAR f     : File;
  67.      result: String;
  68.      act   : LONGINT;
  69.  BEGIN
  70.   Lookup (f, "t:TestFileSystem.tmp", 0, TRUE);
  71.   WriteString (" PROCEDURE WriteBytes"); WriteLn;
  72.   WriteString ("  block = "); WriteString (str); WriteLn;
  73.   WriteBytes (f, ADR(str), SIZE(str), act);
  74.   IF act = SIZE(result) THEN
  75.     WriteString ("Ergebnis ist korrekt.")
  76.   ELSE
  77.     WriteString ("FEHLER!!")
  78.   END;
  79.   WriteLn;
  80.   Close (f);
  81.  
  82.   Lookup (f, "t:TestFileSystem.tmp", 0, FALSE);
  83.   WriteString (" PROCEDURE ReadByteBlock"); WriteLn;
  84.   ReadByteBlock (f, result);
  85.   WriteString ("  block = "); WriteString (result); WriteLn;
  86.   IF Length(result) = SIZE(result) THEN
  87.     WriteString ("Ergebnis ist korrekt.")
  88.   ELSE
  89.     WriteString ("FEHLER!!")
  90.   END;
  91.   WriteLn;
  92.  
  93.   SetPos (f, 0);
  94.   WriteString (" PROCEDURE ReadBytes"); WriteLn;
  95.   ReadBytes (f, ADR(result), SIZE(result), act);
  96.   WriteString ("  block = "); WriteString (result); WriteLn;
  97.   WriteString ("  actual = "); WriteInt (act, 3); WriteLn;
  98.   IF act = SIZE(result) THEN
  99.     WriteString ("Ergebnis ist korrekt.")
  100.   ELSE
  101.     WriteString ("FEHLER!!")
  102.   END;
  103.   WriteLn;
  104.   Close (f);
  105.  END TestWriteBytes;
  106.  
  107.  
  108. BEGIN
  109.  WriteString ("Nur Enter-Taste eingeben für Ausgabe auf Bildschirm!");
  110.  WriteLn;
  111.  WriteString ("Name der Ausgabedatei ");
  112.  OpenOutput ("Errors");
  113.  WriteString ("Test des Moduls FileSystem"); WriteLn;
  114.  WriteLn;
  115.  WriteString (" V3.11d: Prozedur WriteByteBlock fehlerhaft.");
  116.  WriteLn;
  117.  TestWriteByteBlock ("0123456789");
  118.  WriteLn;
  119.  WriteString (" V3.11d: Prozedur ReadByteBlock  fehlerhaft.");
  120.  WriteLn;
  121.  TestWriteBytes     ("0123456789");
  122.  CloseOutput;
  123.  WriteString ("Ende des Tests."); WriteLn
  124. END TestFileSystem.
  125.  
  126.